package org.cqipc.edu.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description: SpringMVC配置
 * @ClassNmae: WebConfig
 * @Author: HeYue
 * @DateTime: 2020-10-30 19:13
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * @Description: 视图控制器
     * @Author: HeYue
     * @DateTime: 2020/10/30 19:15
     **/
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("/html/index.html");
        registry.addViewController("/index").setViewName("/html/index.html");
        registry.addViewController("/index.html").setViewName("/html/index.html");
        registry.addViewController("/login").setViewName("/html/login.html");
        registry.addViewController("/buytoday").setViewName("/html/buytoday.html");
        registry.addViewController("/commodity").setViewName("/html/commodity.html");
        registry.addViewController("/information").setViewName("/html/information.html");
        registry.addViewController("/about").setViewName("/html/about.html");
        registry.addViewController("/shopcart").setViewName("/html/shopcart.html");
        registry.addViewController("/admin").setViewName("/admin.html");
        registry.addViewController("/goods").setViewName("/views/goods.html");
        registry.addViewController("/static/upload").setViewName("/views/upload.html");
        registry.addViewController("/reg").setViewName("/reg.html");
        registry.addViewController("/details").setViewName("/html/details.html");
        registry.addViewController("/register").setViewName("/html/register.html");
        registry.addViewController("/look").setViewName("/html/look.html");
    }


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/upload/**").addResourceLocations("classpath:/upload/");
    }

}
